<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="../../style/css/back/style.css" rel="stylesheet" type="text/css"/>
    <script src="../../style/js/jquery-1.8.3.js"></script>

    <script type="text/javascript">
        $(function () {
            //查询所有的角色
            $.get("../../admin/roles", function (res) {
                var str = "";
                console.log(res.data)
                console.log(res.data.length)
                for (i = 0; i < res.data.length; i++) {
                    str += "<input type='checkbox' value='" + res.data[i].id + "' name='roleId'/>" + res.data[i].name;
                }
                $("#rolesId").html(str);
            }, "json");
        });

        function save() {
            $.post("../../admin/save", $("#formId").serialize(), function (res) {
                if (res.code == 202) {
                    window.parent.location.replace("../login.html");
                } else if (res.code == 500) {
                    alert("服务器忙,请稍后再试!");
                } else {
                    alert("保存成功!");
                    location.replace("list.html");
                }
            });
        }
    </script>
</head>

<body>
<form id="formId">
    <div class="formbody">
        <div class="formtitle"><span>基本信息</span></div>
        <ul class="forminfo">
            <li>
                <label>账号</label>
                <input name="account" type="text" class="dfinput"/>
            </li>
            <li>
                <label>电话</label>
                <input name="phone" type="text" class="dfinput"/>
            </li>
            <li>
                <label>性别</label>
                <input name="sex" type="radio" class="dfinput" value="男"/>男
                <input name="sex" type="radio" class="dfinput" value="女"/>女
            </li>

            <li>
                <label>角色</label>
                <span id="rolesId" class="dfinput">

				</span>
            </li>
            <li>
                <input type="button" class="btn" value="确认保存" onclick="save()"/>
            </li>
        </ul>
    </div>
</form>
</body>

</html>
